<!--  -->
<template>
  <div>
      <van-picker
        title="标题"
        :columns="columns"
        @confirm="onConfirm"
        @cancel="onCancel"
      />
  </div>
</template>

<script>
import { updateUserProfile } from '@/api/user'
export default {
  name: 'GenderPopup',
  data () {
    return {
      columns: ['男', '女']
    }
  },
  methods: {
    onCancel () {
      // 关闭弹出层
      this.$emit('update-genderShow')
    },
    onConfirm (value, index) {
      updateUserProfile({ gender: index }).then(res => {
        // 更新视图
        this.$emit('update-gender', index)
        // 关闭弹出层
        this.$emit('update-genderShow')
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<style  scoped>

</style>
